import axios from "axios";
import { ElMessage } from "element-plus";
import store from "../store"

let http=axios.create({
  baseURL:'http://1.117.75.96:8888/',
  timeout:5000
})

http.interceptors.request.use((config)=>{
  config.headers.token=store.state.user.token
  return config
}, err=>err)

http.interceptors.response.use((res)=>{
  console.log(res);
  if(res.data.code===200){
    return res.data
  }else{
    ElMessage.error(res.data.msg)
    return false
  }
}, err=>err)

export default http